package com.facebook.fresco.samples.showcase.drawee;

import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.fresco.samples.showcase.ResourceTable;
import com.facebook.fresco.samples.showcase.ShowcaseApplication;
import com.facebook.fresco.samples.showcase.misc.ImageUriProvider;
import com.oszc.bbhmlibrary.utils.LogUtil;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.utils.net.Uri;

public class DraweeSimpleAbility extends Ability {
    public static String TAG = DraweeSimpleAbility.class.getSimpleName();
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(com.facebook.fresco.samples.showcase.ResourceTable.Layout_layout_drawee_simple);
        final SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findComponentById(ResourceTable.Id_drawee_view);
        final Component component = findComponentById(ResourceTable.Id_btn_random_uri);
        final Uri uri = ImageUriProvider.createSampleUri(ImageUriProvider.ImageSize.M,null,null);
        simpleDraweeView.setImageURI(uri);
        component.setClickedListener(view -> {
            Uri newImageUri= ShowcaseApplication.imageUriProvider.createSampleUri(ImageUriProvider.ImageSize.M,null,null);
            LogUtil.error(TAG,newImageUri.toString());
            simpleDraweeView.setImageURI(newImageUri);
        });
    }
}
